package com.xbongbong.schedule.domain.dao;

import com.xbongbong.schedule.domain.entity.ScheduleTaskEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
@Mapper
public interface ScheduleTaskDao {

    Integer isTableExist(@Param("tableName") String tableName,@Param("tableSchema") String tableSchema);

    Integer createTable(@Param("tableName") String tableName);

    Integer insert(@Param("tableName") String tableName, @Param("entity") ScheduleTaskEntity entity);

    Integer insertBatch(@Param("tableName") String tableName, @Param("list") List<ScheduleTaskEntity> list);

    Integer update(@Param("tableName") String tableName, @Param("entity") ScheduleTaskEntity entity);

    Integer updateBatch(@Param("tableName") String tableName, @Param("list") List<ScheduleTaskEntity> updateList);

    Integer updateBatchByCorpid(@Param("tableName") String tableName, @Param("list") List<ScheduleTaskEntity> updateList, @Param("corpid") String corpid);

    ScheduleTaskEntity getByKey(@Param("tableName") String tableName, @Param("key") Long id, @Param("corpid") String corpid);

    Integer deleteByKey(@Param("tableName") String tableName, @Param("key") Long id, @Param("corpid") String corpid);

    List<ScheduleTaskEntity> findEntitys(@Param("tableName") String tableName, @Param("param") Map<String, Object> param);

    Integer getEntitysCount(@Param("tableName") String tableName, @Param("param") Map<String, Object> param);

    Integer cancelScheduleTask(@Param("tableName") String tableName, @Param("param") Map<String, Object> param);

    Integer queuedScheduleTaskByIdIn(@Param("tableName") String tableName, @Param("idIn") List<Long> idIn);

    Integer triggeredById(@Param("tableName") String tableName, @Param("corpid") String corpid, @Param("id") Long id, @Param("status") Integer status);
}
